package com.atguigu.servicebase.exceptionhandler;

import com.atguigu.commonutils.ResultCodeEnum;
import lombok.Data;

@Data
public class GuliException extends RuntimeException {

    private  Integer code;

    private String message;

    public GuliException(Integer code, String message){
        super(message);
        this.code = code;
        this.message = message;

    }

    /**
     * 接收枚举类型对象
     * @param resultCodeEnum
     */

    public GuliException(ResultCodeEnum resultCodeEnum){
        super(resultCodeEnum.getMessage());

        this.code = resultCodeEnum.getCode();
        this.message = resultCodeEnum.getMessage();

    }

    @Override
    public String toString() {
        return "GuliException{" +
                "code=" + code +
                ", message='" + message + '\'' +
                '}';
    }
}
